maximum profit calculus